<template lang="jade">
#borrow.current-lending
  //- .header
    a.backup.icon-angle-left(href='javascript:history.go(-1)')
    h1.page-title 借阅服务
  .page-tabs.borrow-tabs.personal-data-tabs
    router-link(to='/borrow/current', active-class='active', @click='switchTab(0)', replace) 当前借阅
    router-link(to='/borrow/history', active-class='active', @click='switchTab(1)', replace) 借阅历史
  router-view(@renew='renew', @renewAll='renewAll')
</template>

<script>
// import api from '../../api-new'

export default {
  data () {
    return {
      switchTab (index) {
        if (index === 0) {
          this.$router.push({
            name: 'borrowCurrent'
          })
        } else if (index === 1) {
          this.$router.push({
            name: 'borrowHistory'
          })
        }
      }
    }
  },
  methods: {
    renew (id) {
      /**
      api.renew(id)
      .then(response => {
        window.alert('续借成功')
      })
      .catch(error => {
        console.log(error)
        window.alert(error.message)
      })
      **/
    },
    renewAll () {}
  }
}
</script>

<style lang='scss'>
.current-lending {
  .header {
    height: 2em;
  }
}
.borrow-tabs {
  a {
    width: 50%;
  }
}
</style>
